package com.yoake.cine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoake.common.annotation.Log;
import com.yoake.common.core.controller.BaseController;
import com.yoake.common.core.domain.AjaxResult;
import com.yoake.common.enums.BusinessType;
import com.yoake.cine.domain.MovieSession;
import com.yoake.cine.service.IMovieSessionService;
import com.yoake.common.utils.poi.ExcelUtil;
import com.yoake.common.core.page.TableDataInfo;

/**
 * 场次信息管理Controller
 * 
 * @author yoake
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/cine/session")
public class MovieSessionController extends BaseController
{
    @Autowired
    private IMovieSessionService movieSessionService;

    /**
     * 查询场次信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:session:list')")
    @GetMapping("/list")
    public TableDataInfo list(MovieSession movieSession)
    {
        startPage();
        List<MovieSession> list = movieSessionService.selectMovieSessionList(movieSession);
        return getDataTable(list);
    }

    /**
     * 导出场次信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:session:export')")
    @Log(title = "场次信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MovieSession movieSession)
    {
        List<MovieSession> list = movieSessionService.selectMovieSessionList(movieSession);
        ExcelUtil<MovieSession> util = new ExcelUtil<MovieSession>(MovieSession.class);
        util.exportExcel(response, list, "场次信息管理数据");
    }

    /**
     * 获取场次信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cine:session:query')")
    @GetMapping(value = "/{sessionId}")
    public AjaxResult getInfo(@PathVariable("sessionId") String sessionId)
    {
        return success(movieSessionService.selectMovieSessionBySessionId(sessionId));
    }

    /**
     * 新增场次信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:session:add')")
    @Log(title = "场次信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieSession movieSession)
    {
        return toAjax(movieSessionService.insertMovieSession(movieSession));
    }

    /**
     * 修改场次信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:session:edit')")
    @Log(title = "场次信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieSession movieSession)
    {
        return toAjax(movieSessionService.updateMovieSession(movieSession));
    }

    /**
     * 删除场次信息管理
     */
    @PreAuthorize("@ss.hasPermi('cine:session:remove')")
    @Log(title = "场次信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sessionIds}")
    public AjaxResult remove(@PathVariable String[] sessionIds)
    {
        return toAjax(movieSessionService.deleteMovieSessionBySessionIds(sessionIds));
    }
}
